/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.feedback.manage.service;


import info.peigen.hotpot.common.core.result.PageResult;
import info.peigen.hotpot.component.feedback.form.FeedbackManageAddForm;
import info.peigen.hotpot.component.feedback.form.FeedbackManageDeleteForm;
import info.peigen.hotpot.component.feedback.form.FeedbackManageEditForm;
import info.peigen.hotpot.component.feedback.form.FeedbackManageSearchForm;
import info.peigen.hotpot.component.feedback.repository.service.FeedbackRepository;
import info.peigen.hotpot.component.feedback.result.FeedbackCreateResult;
import info.peigen.hotpot.component.feedback.result.FeedbackDeleteResult;
import info.peigen.hotpot.component.feedback.result.FeedbackEditResult;
import info.peigen.hotpot.component.feedback.result.info.FeedbackManageInfo;
import info.peigen.hotpot.component.feedback.service.FeedbackService;
import info.peigen.hotpot.component.feedback.service.order.FeedbackCreateOrder;
import info.peigen.hotpot.component.feedback.service.order.FeedbackDeleteOrder;
import info.peigen.hotpot.component.feedback.service.order.FeedbackEditOrder;
import info.peigen.hotpot.component.feedback.util.FeedbackManageConvertor;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;

/**
 * <b>(FeedbackManageService)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/1/6
 */
@SuppressWarnings("AlibabaServiceOrDaoClassShouldEndWithImpl")
@Component
public class FeedbackManageService {
    @Inject
    private FeedbackRepository feedbackRepository;
    @Inject
    private FeedbackService    feedbackService;

    public PageResult<FeedbackManageInfo> page(FeedbackManageSearchForm form) {
        PageResult<FeedbackManageInfo> page = feedbackRepository.page(form.getPageNum(), form.getPageSize(), FeedbackManageConvertor::convertToInfo);
        return page;
    }

    public FeedbackCreateResult add(FeedbackManageAddForm form) {
        FeedbackCreateOrder order = FeedbackManageConvertor.convertOrder(form);
        return feedbackService.create(order);
    }

    public FeedbackEditResult edit(FeedbackManageEditForm form) {
        FeedbackEditOrder order = FeedbackManageConvertor.convertOrder(form);
        return feedbackService.edit(order);
    }

    public FeedbackDeleteResult delete(FeedbackManageDeleteForm form) {
        FeedbackDeleteOrder order = FeedbackManageConvertor.convertOrder(form);
        return feedbackService.delete(order);
    }
}